<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        console.log('--------------------1--------------------');
        let hero = {
            name: "李白",
            level: 15,
            skill: function (age) {
                console.log(age + "青莲剑歌");
            }
        }


        //1.获取对象属性的两种方式
        //对象名.属性名
        //对象名[字符串]  字符串为属性名          对象名["属性名"]
        console.log(hero.name);
        console.log(hero['level']);

        //2.变量是 window 的属性
        console.log('--------------------2--------------------');


        var age = 22;


        //3.window一般省略
        console.log('--------------------3--------------------');


        console.log(age);
        console.log(window.age);

        //4.对象方法的调用
        console.log('--------------------4--------------------');

        hero.skill();
        hero.skill();

        function eat() {
            console.log("将进酒");
        }
        eat();
        window.eat();



        //5.对象可以动态的添加属性（方法）
        console.log('--------------------5--------------------');

        hero.address = "酒剑仙";
        hero.play = function() {
            console.log('王者荣耀');
        }
        console.log(hero);
        hero.play();



        //6.属性的修改（变量的重新赋值）
        console.log('--------------------6--------------------');

        hero.name = "亚瑟王";
        console.log(hero);

        //7.属性的删除（delete）  对象名.属性名
        console.log('--------------------7--------------------');

        delete hero.name;
        console.log(hero)
    </script>
</body>

</html>